package chapter13;

/**
 * @author : DuJiabao
 * @Date : 2021/2/21 10:49
 * @Project : thinking-in-java
 * @File : null.java
 * @Desc :
 */
public class InternTest {
  public static void main(String[] args) {
    String s0 = "123456";
    String s1 = new String("123456");
    String s2 = "123" + "456";
    String s3 = new String("123") + "456";

    System.out.println(s0 == s1);  // false
    System.out.println(s0.intern() == s1.intern());   //true

    System.out.println(s0 == s2);  //true
    System.out.println(s0.intern() == s2.intern());  //true

    System.out.println(s0 == s3);  //false
    System.out.println(s0.intern() == s3.intern());  //true
  }
}
